#version 120


uniform float time;
varying vec4 vertex;

varying vec2 vTexCoord2D;                                  //stegu


varying float fogFactor;    //fog


void main(void) {
    //vec3 lightDir = normalize(vec3(gl_LightSource[0].position));
	
	vec4 outVert;				// used to hold results of vertex calcs
	vec4 curVert = gl_Vertex;	// used to hold the current vertex we're on
	outVert = curVert;
	outVert.z = sin(outVert.x + outVert.y + time)*0.3;	
	// set the texture coordinate to keep the texture on the model
	//vertex = outVert;
	
	//the fog
	vec3 vVertex = vec3(gl_ModelViewMatrix * gl_Vertex);
	gl_FogFragCoord = length(vVertex);                                 //
	fogFactor = (gl_Fog.end - gl_FogFragCoord)/(gl_Fog.end - gl_Fog.start);
	fogFactor = clamp(fogFactor, 0.0, 1.0);
				   
	
	vTexCoord2D = gl_Vertex.xy * 0.5;                      //stegu
	//gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;//stegu
	
	// set the vertex position
	// we're changing the vertex position so instead of gl_ModelViewProjectionMatrix * gl_Vertex (ftransform()) we use the new vertex position
	gl_Position = vec4(gl_ModelViewProjectionMatrix * outVert);
}
